home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / include / host.h < prev    next >
C/C++ Source or Header  |  1990-11-07  |  3KB  |  93 lines

  1. /*
  2.  * host.h --
  3.  *    Header file for users of the Host_ functions. These functions
  4.  *    access a database of all Sprite hosts on the local network, giving
  5.  *    various information about the host that is needed to communicate
  6.  *    with it in various ways...
  7.  *
  8.  * Copyright (c) 1987 by the Regents of the University of California
  9.  * Permission to use, copy, modify, and distribute this
  10.  * software and its documentation for any purpose and without
  11.  * fee is hereby granted, provided that the above copyright
  12.  * notice appear in all copies.  The University of California
  13.  * makes no representations about the suitability of this
  14.  * software for any purpose.  It is provided "as is" without
  15.  * express or implied warranty.
  16.  *
  17.  *    "$Header: /sprite/src/lib/include/RCS/host.h,v 1.6 90/11/06 16:51:15 jhh Exp $ SPRITE (Berkeley)"
  18.  */
  19.  
  20. #ifndef _HOST
  21. #define _HOST
  22.  
  23. #ifndef _TYPES
  24. #include <sys/types.h>
  25. #endif
  26. #ifndef _IN
  27. #include <netinet/in.h>
  28. #endif
  29.  
  30. #include <sys/stat.h>
  31. /*
  32.  * A host information file contains lines of the following form:
  33.  *
  34.  * <spriteID> <netType> <netAddr> <inetAddr> <machType> <name> <aliases>
  35.  *
  36.  * Where the fields are as follows:
  37.  *    spriteID        The Sprite ID for the host (small number)
  38.  *    netType         Type of local network by which the machine is
  39.  *                      connected. Currently, only "ether" and "inet" 
  40.  *                      are understood.
  41.  *    netAddr              Address for the local network
  42.  *    inetAddr          The internet address of the host
  43.  *    machType        The machine type.  This string value is used
  44.  *                when expanding $MACHINE in pathnames.
  45.  *    name              The official name for the machine
  46.  *    aliases              Other names for the machine
  47.  */
  48.  
  49. /*
  50.  * A Host_Entry contains the broken out fields of the host table line
  51.  * for a host.
  52.  *
  53.  * Sprite hosts may be connected to the network by different local-area-nets
  54.  * (LANs). The netType field of the Host_Entry tells what type of network
  55.  * it is. The Addr field in the netAddr union should be chosen based on
  56.  * this type.
  57.  *
  58.  */
  59. typedef enum {
  60.     HOST_ETHER,
  61.     HOST_INET
  62. } Host_NetType;
  63.  
  64. #define HOST_ETHER_ADDRESS_SIZE 6
  65.  
  66. typedef struct {
  67.     char              *name;      /* Primary name */
  68.     char              **aliases;  /* Other names */
  69.     int                  id;        /* Sprite ID */
  70.     struct in_addr    inetAddr;   /* Internet address */
  71.     Host_NetType      netType;    /* Network used to connect to host */
  72.     union {
  73.     unsigned char    etherAddr[HOST_ETHER_ADDRESS_SIZE];
  74.                     /* Ethernet address of machine or 
  75.                      * first gateway if netType is HOST_INET. */
  76.     }                  netAddr;    /* Address for that network */
  77.    char            *machType;  /* Machine type, i.e "sun3", "spur" */
  78. } Host_Entry;
  79.  
  80. /*
  81.  * Accessor functions
  82.  */
  83. Host_Entry *    Host_ByID();        /* Find host entry by Sprite ID */
  84. Host_Entry *    Host_ByInetAddr();    /* Find by Internet address */
  85. Host_Entry *    Host_ByName();        /* Find entry by name */
  86. Host_Entry *    Host_ByNetAddr();    /* Find by LAN address */
  87. void        Host_End();        /* Close host description file */
  88. Host_Entry *    Host_Next();        /* Retrieve next entry in file */
  89. int        Host_SetFile();        /* Change file to read for info */
  90. int        Host_Start();        /* Open host description file */
  91.  
  92. #endif /* _HOST */
  93.